﻿@using 第五课.Models.Database;
<div class="container">
    <!-- InstanceBeginEditable name="MainBody" -->
    <link rel="stylesheet" type="text/css" href="/css/household.css" />
    <link rel="stylesheet" type="text/css" href="/css/goods-item.css" />
    <div class="phone-market">
        <div class="banner">
            <div class="xgs-row">
                <img src="/img/household/banner.png" width="100%" height="300">
            </div>
        </div>
    </div>
    <!--  -->
    <div class="household-container  goods-item">
        <div class="xgs-row" style="padding: 0;background-color: white;">
            <ul class="household-navtab" style="display: inline-block;">
                @* 3、渲染数据 *@
                @* 转换类型 *@
                @* @ViewData["Cates"] 1、直接使用变量 *@
                @* cs+html c# @{} 2、实现多行代码编写 *@

                @{
                    //转换类型
                    var cates = ViewData["Cates"] as List<Category>;
                    foreach (var item in cates)
                    {
                        if ((int)ViewData["cateId"] == item.Id)
                        {
                            <li><a style="background-color: #69c0ff;color: white;" href="/market.html?cateId=@item.Id">@item.CateName</a></li>
                        }
                        else
                        {
                            @* @item.CateName  分类对象.分类名字  *@
                            <li><a href="/market.html?CateId=@item.Id">@item.CateName</a></li>
                        }

                    }
                }
                @*<li><a style="background-color: #69c0ff;color: white;" href="javascript:void(0);">文学</a></li>
        <li><a href="javascript:void(0);">经管</a></li>
        <li><a href="javascript:void(0);">少儿</a></li>
        <li><a href="javascript:void(0);">文教</a></li>
        <li><a href="javascript:void(0);">科技</a></li>
        <li><a href="javascript:void(0);">艺术</a></li>*@
            </ul>
        </div>

        <div class="tab-item white-panel" style="padding: 20px 0;margin-top: 20px;">
            <!-- 文学 -->
            <div id="wenxue" class="wenxue">

                @{
                    //转换类型
                    var goods = ViewData["Goods"] as List<Good>;
                    //共多少行（页）->row
                    var row = 0;
                    if (goods.Count % 4 == 0)
                    {
                        row = goods.Count / 4;
                    }
                    else
                    {
                        row = (goods.Count / 4) + 1;
                    }

                    for (int i = 1; i <= row; i++)
                    {
                        <div class="xgs-row">
                            @{
                                var list = goods.Skip((i - 1) * 4).Take(4).ToList();
                                foreach (var item in list)
                                {
                                    <div class="xgs-col4">
                                        <a href="detail.html?id=@item.Id">
                                            <div>
                                                <img src="@item.Cover" alt="">
                                                <span class="goods-title">
                                                    @item.Name
                                                </span>
                                                <p class="price">￥@item.Price</p>
                                            </div>
                                        </a>
                                    </div>
                                }
                            }
                        </div>
                    }
                }
            </div>
            <!-- /文学 -->
        </div>
    </div>
    <!-- InstanceEndEditable -->
</div>
